<html>
<head><meta charset="utf-8"><title>ELF Relo Entries · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/ELF.20Relo.20Entries.html">ELF Relo Entries</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217059747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/ELF%20Relo%20Entries/near/217059747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kevin Knapp <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/ELF.20Relo.20Entries.html#217059747">(Nov 17 2020 at 20:43)</a>:</h4>
<p>Please forgive me if this is the wrong place to ask this type of question, but does anyone have any experience with the low level details of how/why Rust utilizes static data in the .rodata section of ELF binaries? I'm having an issue where for the target I'm using, certain symbols must be loaded in particular ELF sections (using <code>#[link_section = ".."]</code>). However, Rust (or LLVM?) keeps inserting relocation entries from the correct sections into .rodata which the target does not know how to handle. To make it even more strange, if I only use one symbol, everything works, but if I add a second static the relocations to .rodata pop up and everything breaks. I'm guessing it has to do with something about size? But I'm a bit lost on where I can control this type of behavior within the compiler</p>



<a name="217116375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/ELF%20Relo%20Entries/near/217116375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/ELF.20Relo.20Entries.html#217116375">(Nov 18 2020 at 10:15)</a>:</h4>
<p>Does it work with <code>-Zrelro-level=off</code>? You will need to use a nightly rustc for that.</p>



<a name="217274047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/ELF%20Relo%20Entries/near/217274047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kevin Knapp <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/ELF.20Relo.20Entries.html#217274047">(Nov 19 2020 at 14:12)</a>:</h4>
<p>I've tried <code>-C link-arg=norelro</code> which I thought was the same, but it did not change anything. I found some custom forks of Rust that add BPF as a target, so I'm currently going through the process to update them to the latest nightly and see if that changes anything. There are a few minor differences between the <code>x86_64-unknown-linux-gnu</code> and BPF target, but nothing that I think would make much difference here. Even in real world examples I don't see many people use <code>clang</code>s <code>-target=bpf</code> option because they're just emitting LLVM bitcode and then later relying on <code>llc --march=bpf</code> which is the same workflow I'm using here.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>